package com.dragon.im.controller;


import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.dragon.im.pojo.ImOrderTracking;
import com.dragon.im.service.OrderTrackingService;
import com.dragon.im.util.Result;

@Controller
public class OrderTrackingController {
	private static final Logger logger = LoggerFactory.getLogger(OrderTrackingController.class);
	@Autowired
	OrderTrackingService otService;
	
	
	@ResponseBody
	@RequestMapping("paging.do")
	public Result paging(int total,int page) {
		System.out.println("coming");
		Result res = otService.findByPage(total, page);
		return res;
	}
	
	@ResponseBody
	@RequestMapping("findById.do")
	public Result findById(Long id) {
		
		Result res = otService.findById(id);
		return res;
//		ImOrderTracking orderTracking = otMapper.findById(id);
//		System.out.println(orderTracking);
//		List<ImOrderTracking> list = new ArrayList<>();
//		list.add(orderTracking);
//		Result res = new Result(1,list,null);
//		return res;
	}
	
	@ResponseBody
	@RequestMapping("update.do")
	public Result update(ImOrderTracking orderTracking) {
		
		
		Result result = otService.update(orderTracking);
		logger.info("update success!");
		return result;
	}
	
	@ResponseBody
	@RequestMapping("add.do")
	public Result add(ImOrderTracking orderTracking) {
		Result result = otService.add(orderTracking);
		logger.info("add success!");
		return result;
	}
	
	@ResponseBody
	@RequestMapping("delete.do")
	public Result delete(Long id) {
		Result result =  otService.delete(id);
		logger.info("delete success!");
		return result;
		
	}
}
